package cn.chenlh.fx.component;

import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.control.TextField;

public class Input extends TextField {

    public static Input of(double w) {
        Input input = new Input();
        input.setWidth(w);
        return input;
    }

    public static Input of(double w, double h) {
        Input input = new Input();
        input.setSize(w, h);
        return input;
    }

    public void setSize(double w, double h) {
        setMinSize(w, h);
        setMaxSize(w, h);
    }

    public void click(EventHandler<ActionEvent> eventHandler) {
        setOnAction(eventHandler);
    }

    public String getVal() {
        return getText().trim();
    }

}
